package com.pi.iot.repository.huawei.constants;

import java.util.ArrayList;
import java.util.List;

/**
 * @description IOT平台的通知类型
 * @author chenmfa
 */
public enum NotifyType {
  SERVICE_INFO_CHANGED(1, "serviceInfoChanged"),
  DEVICE_INFO_CHANGED(2, "deviceInfoChanged"),
  DEVICE_DATA_CHANGED(3, "deviceDataChanged"),
  DEVICE_ADDED(4, "deviceAdded"),
  DEVICE_DELETED(5, "deviceDeleted"),
  MESSAGE_CONFIRM(6, "messageConfirm"),
  COMMAND_RSP(7, "commandRsp"),
  DEVICE_EVENT(8, "deviceEvent"),
  RULE_EVENT(9, "ruleEvent"),
  DEVICE_DATAS_CHANGED(10, "deviceDatasChanged"),
  ;
  private int code;
  private String notifyType;
  private NotifyType(int code, String notifyType) {
    this.notifyType = notifyType;
  }
  
  public static List<String> getNotifyTypes () {
    List<String> notifyList = new ArrayList<>();
    for(NotifyType notifyTypeEnum: NotifyType.values())
      notifyList.add(notifyTypeEnum.getNotifyType());
    return notifyList;
  }
  
  public static NotifyType getNotifyType(String notifyType) {
    if(null == notifyType)
      return null;
    for(NotifyType notifyTypeEnum: NotifyType.values())
      if(notifyTypeEnum.getNotifyType().equalsIgnoreCase(notifyType))
        return notifyTypeEnum;
    return null;
  }
  
  public String getNotifyType() {
    return notifyType;
  }
  public int getCode() {
    return code;
  }
}
